package com.codermn.day721;

import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.*;
import javax.swing.*;

public class ShangXian extends JFrame implements ActionListener
{ 
	private JLabel label1;
	 JTextField userName;
	private JButton getIn;
	private JPanel panel;
	ShangXian()
	{
		super("ˮ����������");
		Container con=getContentPane();
		con.setLayout(new FlowLayout());
		label1=new JLabel("�û�����");
		userName=new JTextField("--�������û���--");
		userName.addMouseListener(new MouseAdapter(){

			public void mouseClicked(MouseEvent arg0) {
				if(userName.getText().equals("--�������û���--")){
					userName.setText("");
				}
			}
		});
		getIn=new JButton("����");
		getIn.addActionListener(this);
		panel=new JPanel();
		panel.setLayout(new FlowLayout());
		panel.add(label1);panel.add(userName);panel.add(getIn);
		con.add(panel);
		setBounds(400,200,240,100);
		setResizable(false);
		setVisible(true);
		validate();
		
	}
	

	@Override
	public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
		
		if(!userName.getText().equals("")&&!userName.getText().equals("--�������û���--"))
		{		
			try {
				Client client=new Client(userName.getText());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			setVisible(false);
		}
				
	}
	
	public static void main(String[]args)
	{
		new ShangXian();
	}

}
